﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.Utilities;
using System.IO;
using System.Xml.Serialization;
using System.Xml;

namespace VsSpeakerCompanion
{
    /// <summary>
    /// Manages settings that could be shared between different instances of the Speaker
    /// </summary>
    public class SharedSettings : Settings
    {
        private const string DefaultSettingsPath = @"Settings-shared.xml";

        /// <summary>
        /// Creates a new instance of <see cref="SharedSettings"/>
        /// </summary>
        public SharedSettings()
            : base(DefaultSettingsPath)
        { }
        
        /// <summary>
        /// Updates the setting value for the specified key
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        public override void Update(string key, object value)
        {
            Load();
            base.Update(key, value);
            Save();
        }

        /// <summary>
        /// Gets the setting value for the specified key
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <returns></returns>
        public override T Get<T>(string key)
        {
            Load();
            return base.Get<T>(key);
        }
    }
}